package top.kaoshanji.q1ch05a;

import org.junit.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import top.kaoshanji.q1ch05a.web.HomeController;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/4/24 10:12
 */
public class HomeControllerTest {

    /**
     * 代码清单test-q1ch05a-146页a：改进HomeControllerTest
     * @throws Exception 测试
     */
    @Test
    public void testHomePage() throws Exception {
        HomeController controller = new HomeController();

        MockMvc mockMvc = MockMvcBuilders.standaloneSetup(controller).build();

        mockMvc.perform(MockMvcRequestBuilders.get("/home")).
                andExpect(MockMvcResultMatchers.view().name("homePage"));

    }

}
